package service;

import models.Orgn;

import org.springframework.stereotype.Service;

@Service("orgnService")
public class OrgnService extends BaseManager {

	public String getUserOrgnString(Orgn orgn, boolean shortName) {

		if (shortName)
			return orgn.getName();

		String rt = "";
		for (; orgn != null;) {
			rt = orgn.getName() + rt;
			if(orgn.getParent()==null)break;
			orgn = getDao().getById(Orgn.class, orgn.getParent().getId(),
					"parent");
			if(orgn!=null){
				rt = " " + rt;
			}
		}
		return rt;
	}
}
